#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

vector<int> v;
void func(int* a,int y,int sum){
	if(y==1){
		for(int i=0;a[i]!=0;++i){
			v.push_back(sum+a[i]);
		}
		return;

	}
	for(int i=0;a[i]!=0;++i){
		func(&a[i+1],y-1,sum+a[i]);
	}
	return;
}

bool is_sushu(int a){
	int b=(int)sqrt(a);
	for(int i=2;i<=b;i++){
		if(a%i==0)return false;
	}
	return true;
}

int main(void){
	int a[21]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	int n,k,total=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	func(a,k,0);
	for(int i=0;i<v.size();i++){
		if(is_sushu(v[i]))total++;
	}
	cout<<total;
}
